package com.sy.controller.admin;

import com.sy.dto.CourseUserPageQueryDTO;
import com.sy.result.PageResult;
import com.sy.result.Result;
import com.sy.service.CourseUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 报名课程管理
 */
@Api(tags = "报名课程管理相关接口")
@RestController
@RequestMapping("/admin/courseUser")
@Slf4j
public class CourseUserController {

    @Autowired
    private CourseUserService courseUserService;

    /**
     * 报名课程分页查询
     * @param courseUserPageQueryDTO
     * @return
     */
    @ApiOperation("报名课程分页查询")
    @GetMapping("/findAll")
    public Result<PageResult> findAll(CourseUserPageQueryDTO courseUserPageQueryDTO) {
        //打印请求数据日志
        log.info("课程分页查询：{}", courseUserPageQueryDTO);
        //调用业务层实现分页查询
        PageResult pageResult = courseUserService.findAll(courseUserPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 添加课程明细
     *
     * @param coursedetail
     * @return
     */
    /*@ApiOperation("添加课程明细")
    @PostMapping("/save")
    public Result<String> save(@RequestBody Coursedetail coursedetail) {
        try {
            //设置添加课程的当前时间
            coursedetail.setCreateTime(LocalDateTime.now());
            coursedetailService.save(coursedetail);
            return Result.success();
        } catch (Exception e) {
            //e.printStackTrace();
            throw new RuntimeException("修改失败");
        }
    }*/
}